
package
{
	import com.learnosity.extendotext.ExtendoText;
	import com.learnosity.extendotext.StyleSheet;
	import com.learnosity.extendotext.style.Color;
	
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.display.Shape;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.text.TextField;
	import flash.text.TextFormat;
	import flash.text.engine.*;
	import flash.utils.Dictionary;
	
	import flashx.textLayout.formats.TextAlign;
	
	
	/**
	 * @author 缺硒
	 */
	public class TextShow extends Sprite
	{
		private static var __textFormat:TextFormat = new TextFormat();
	
		private var _txt:TextField;
		private var _speed:Number;
		
		private var text_line:TextLine;
		
		private var etext:ExtendoText;
		
		// 构造函数
		public function TextShow()
		{
			_speed = Math.random() * 5 + 1;
			
//			var font_description:FontDescription = new FontDescription();
//			font_description.fontName="Verdana";
//			font_description.fontWeight=FontWeight.BOLD;
//			font_description.fontPosture=FontPosture.ITALIC;
//			font_description.renderingMode=RenderingMode.CFF;
//			font_description.locked=true;
//			var element_format:ElementFormat=new ElementFormat(font_description);
//			element_format.fontSize=Math.random() * 50 + 12;
//			element_format.kerning=Kerning.ON;
//			element_format.color=0x000000;
//			element_format.alpha=1;
//			var text_element:TextElement=new TextElement("Hello Flash World",element_format);
//			var text_block:TextBlock = new TextBlock();
//			text_block.content=text_element;
//			text_line=text_block.createTextLine(null,500);
//			text_line.y=Math.random() * 600;
//			addChild(text_line);
			

			_txt = new TextField();
			_txt.autoSize = TextAlign.LEFT;
			__textFormat.size = Math.random() * 50 + 12;
		
			_txt.text = "asdfasd";
			_txt.setTextFormat(__textFormat);
			var bmp:BitmapData = new BitmapData(_txt.width,_txt.height,true,0x000000);
			bmp.draw(_txt);
			addChild(new Bitmap(bmp));
//			this.graphics.beginBitmapFill(bmp,null,false);
//			this.graphics.drawRect(0,0,bmp.width,bmp.height);
//			this.graphics.endFill();
//			this.graphics.clear();
//			addChild(_txt);
			
//			etext = new ExtendoText(new Dictionary(), new StyleSheet());
//			etext.text = "asdfasd";
//			etext.y = Math.random() * 600;
//			addChild(etext);
			addEventListener(Event.ENTER_FRAME, onEnterFrame);
			this.y = Math.random() * 600;
		}
		
		private function onEnterFrame(evt:Event):void
		{
//			_txt.x += _speed;
//			text_line.x += _speed;
			
			this.x += _speed;
			if(this.x > 900)
			{
				removeEventListener(Event.ENTER_FRAME, onEnterFrame);
				this.parent.removeChild(this);
			}
		}
		//
	}
}